// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic','starter.controllers', 'starter.services'])

  .run(function($ionicPlatform, $ionicPopup, $rootScope, $timeout, $location,$ionicHistory) {
    $ionicPlatform.ready(function() {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
        cordova.plugins.Keyboard.disableScroll(true);

      }

      window.addEventListener('native.keyboardhide',function (e){
        cordova.plugins.Keyboard.isVisible = true;
        $timeout(function() {
          cordova.plugins.Keyboard.isVisible = false;
        },100);

      });
      $ionicPlatform.registerBackButtonAction(function (e) {
        if($ionicHistory.backView()) {
          if( window.cordova.plugins.Keyboard.isVisible) {
            window.cordova.plugins.Keyboard.close();
          }else {
            if ($location.path() == '/tab/home' ) {
              $ionicHistory.clearHistory();
            }
            else
              $ionicHistory.goBack();
          }
        }
      }, 101);

      if (window.StatusBar) {
        // org.apache.cordova.statusbar required
        StatusBar.styleDefault();
      }
    });
  })

  .config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) {

    $ionicConfigProvider.platform.ios.tabs.style('standard');
    $ionicConfigProvider.platform.ios.tabs.position('bottom');
    $ionicConfigProvider.platform.android.tabs.style('standard');
    $ionicConfigProvider.platform.android.tabs.position('standard');

    $ionicConfigProvider.platform.ios.navBar.alignTitle('center');
    $ionicConfigProvider.platform.android.navBar.alignTitle('center');

    $ionicConfigProvider.platform.ios.backButton.previousTitleText('').icon('ion-ios-arrow-thin-left');
    $ionicConfigProvider.platform.android.backButton.previousTitleText('').icon('ion-android-arrow-back');

    $ionicConfigProvider.platform.ios.views.transition('ios');
    $ionicConfigProvider.platform.android.views.transition('android');

    // Ionic uses AngularUI Router which uses the concept of states
    // Learn more here: https://github.com/angular-ui/ui-router
    // Set up the various states which the app can be in.
    // Each state's controller can be found in controllers.js
    $stateProvider

    // setup an abstract state for the tabs directive
      .state('tab', {
        url: '/tab',
        abstract: true,
        cache:'false',
        templateUrl: 'templates/tabs.html'
      })

      // Each tab has its own nav history stack:

      .state('tab.home', {
        url: '/home',
        views: {
          'tab_home': {
            templateUrl: 'templates/tab_home.html',
            controller: 'homeCtrl'
          }
        }

      })
      .state('tab.setting', {
        url: '/setting',
        cache:'false',
        views: {
          'tab_setting': {
            templateUrl: 'templates/tab_setting.html',
            controller: 'settingCtrl'
          }
        }
      })
      .state('tab.account', {
        url: '/account',
        views: {
          'tab_account': {
            cache:'false',
            templateUrl: 'templates/tab_account.html',
            controller: 'AccountCtrl'
          }
        }
      })
      .state('chengdu_holi', {
        url: '/chengdu_holi',
        cache:'false',
        templateUrl: 'templates/chengdu_holi.html',
        controller:"holi0Ctrl"
      })
      .state('jidi_holi', {
        url: '/jidi_holi',
        cache:'false',
        templateUrl: 'templates/jidi_holi.html',
        controller:"holi1Ctrl"
      })  //工作日 成都方向班车
      .state('chengdu_work', {
        url: '/chengdu_work',
        cache:'false',
        templateUrl: 'templates/chengdu_work.html'

      })  //工作日 基地方向班车
      .state('jidi_work', {
        url: '/jidi_work',
        cache:'false',
        templateUrl: 'templates/jidi_work.html',

      })
      .state('query_phone', {
        url: '/query_phone',
        cache:'false',
        templateUrl: 'templates/query_phone.html',
        controller:"queryPhoneCtrl"
      })  //更新密码
      .state('update_password', {
        url: '/update_password',
        cache:'false',
        templateUrl: 'templates/set/update_password.html',
        controller:"settingUpdatePasswordCtrl"
      })
      .state('check', {
        url: '/check',
        cache:'false',
        templateUrl: 'templates/check/check.html'
      })  //员工审核页面
      .state('check/check_employee_detail', {
        url: '/check/check_employee_detail',
        cache:'false',
        templateUrl: 'templates/check/check_employee_detail.html'
      }) //员工家属详细
      .state('check/check_family_detail', {
        url: '/check/check_family_detail',
        cache:'false',
        templateUrl: 'templates/check/check_family_detail.html'
      })
      // 车票审核
      .state('check_ticket', {
        url: '/check_ticket',
        cache:'false',
        templateUrl: 'templates/check/check_ticket.html'
      })
      // 车票审核详情
      .state('check/check_ticket_detail', {
        url: '/check/check_ticket_detail',
        cache:'false',
        params:{ticketInfo:null},
        controller:"checkTicketDetailCtrl",
        templateUrl: 'templates/check/check_ticket_detail.html'
      })
      //拼车拼玩内容展示
      .state('personal_car', {
        url: '/personal_car',
        cache:'false',
        templateUrl: 'templates/pinche/personal_car.html',
        controller: "perCarCtrl"
      })  //拼车拼玩添加
      .state('car_publish', {
        url: '/car_publish',
        cache:'false',
        templateUrl: 'templates/pinche/car_publish.html',
        controller:"carPoolingInsertCtrl"
      })  //拼车拼玩详细
      .state('car_detail', {
        url: '/car_detail',
        cache:'false',
        params:{category:null},
        templateUrl: 'templates/pinche/car_detail.html',
        controller: "carDetailCtrl"
      })
      //我的车票 工作日
      .state('my_tickets_work', {
        url: '/my_tickets_work',
        cache:'false',
        templateUrl: 'templates/my_tickets_work.html',
        controller: 'myTicketsCtrlWork'
      })  //我的车票  假期
      .state('my_tickets_holi', {
        url: '/my_tickets_holi',
        cache:'false',
        templateUrl: 'templates/my_tickets_holi.html',
        controller: 'myTicketsCtrlHoli'
      })  //亲属
      .state('my_family', {
        url: '/my_family',
        cache:'false',
        templateUrl: 'templates/my_family.html',
        controller: 'myFamilyCtrl'
      })  //添加亲属
      .state('add_family', {
        url: '/add_family',
        cache:'false',
        templateUrl: 'templates/add_family.html',
        controller:'addRelativeCtrl'
      })  //通知
      .state('notice', {
        url: '/notice',
        cache:'false',
        templateUrl: 'templates/notice.html',
        controller:'noticeCtrl'
      })  //假期成都方向订座详情
      .state('seat_detail', {
        url: '/seat_detail',
        cache:'false',
        params:{bus:null,orientation:null},
        templateUrl: 'templates/seats_detail.html',
        controller:"seatDetailCtrl"
      }) //假期基地方向订座详情
      .state('seat_detail1', {
        url: '/seat_detail1',
        cache:'false',
        params:{bus:null,orientation:null},
        templateUrl: 'templates/seats_detail1.html',
        controller:"seatDetailCtrl"
      })  //工作日班车成都方向订座详情
      .state('seats_detail_work0', {
        url: '/seats_detail_work0',
        cache:'false',
        params:{bus:null},
        templateUrl: 'templates/seats_detail_work0.html',
        controller:"seatDetail1WorkCtrl"
      }) //工作日班车基地方向订座详情
      .state('seats_detail_work1', {
        url: '/seats_detail_work1',
        cache:'false',
        params:{bus:null},
        templateUrl: 'templates/seats_detail_work1.html',
        controller:"seatDetail1WorkCtrl"
      })  //通知
      .state('notice_detail', {
        url: '/notice_detail',
        params:{'notice':null},
        cache:'false',
        templateUrl: 'templates/notice_detail.html',
        controller:"noticeDetailCtrl"
      })  //设置 关于
      .state('setting-about', {
        url: '/setting-about',
        cache:'false',
        templateUrl: 'templates/set/about.html',
        controller:"settingAboutCtrl"
      })  //帮助
      .state('setting-help', {
        url: '/setting-help',
        cache:'false',
        templateUrl: 'templates/set/help.html',
        controller:"settingHelpCtrl"
      }) //班车规章
      .state('setting-busRule', {
        url: '/setting-busRule',
        cache:'false',
        templateUrl: 'templates/set/busRule.html',
        controller:"settingBusRuleCtrl"
      })  //软件规则
      .state('setting-softRule', {
        url: '/setting-softRule',
        cache:'false',
        templateUrl: 'templates/set/softRule.html',
        controller:"settingSoftRuleCtrl"
      })
      //意见反馈
      .state('setting-feedback', {
        url: '/setting-feedback',
        cache:'false',
        templateUrl: 'templates/set/feedback.html',
        controller:"settingFeedbackCtrl"
      }) //登录
      .state('signin', {
        url: '/signin',
        cache:'false',
        templateUrl: 'templates/signin.html',
        controller:'signinCtrl'
      })  //注册
      .state('signup', {
        url: '/signup',
        cache:'false',
        templateUrl: 'templates/signup.html',
        controller:'signupCtrl'
      })  //编辑用户信息
      .state('modifyStaff',{
        url:"/modifyStaff",
        cache:'false',
        templateUrl:'templates/edit_account.html',
        controller:'modifyStaffCtrl'
      })  //更换车票
      .state('changeTicketHoli',{
        url:'/changeTicketHoli',
        cache:'false',
        templateUrl:'templates/change_ticket_holi.html',
    })  //生活地图
     .state('lifeMap',{
      url:'/lifeMap',
      cache:'false',
      templateUrl:'templates/map/life.html',
    }).state('community',{
      url:'/community',
      cache:'false',
      templateUrl:'templates/bbs/community.html',
    })   //测试练题
      .state('exam',{
        url:'/exam',
        cache:'false',
        templateUrl:'templates/test/exam.html',
      })//练题测试 党章
      .state('dangzhang',{
        url:'/exam/dangzhang',
        cache:'false',
        templateUrl:'templates/test/dangzhang.html',
      })  //小黑板显示
      .state('newsBlackBoard',{
        url:'/newsBlackBoard',
        cache:'false',
        templateUrl:'templates/blackboard/newsBlackBoard.html',
      }) //小黑板添加
      .state('newsBlackBoardAdd',{
        url:'/newsBlackBoardAdd',
        cache:'false',
        templateUrl:'templates/blackboard/newsBlackBoardAdd.html',
      }) //小黑板详细内容
      .state('newsBlackBoardDetail',{
        url:'/newsBlackBoardDetail',
        params:{'news':null},
        cache:'false',
        templateUrl:'templates/blackboard/newsBlackBoardDetail.html',
      })
    ;

    // if none of the above states are matched, use this as the fallback
    $urlRouterProvider.otherwise('/tab/home');

  });
